//
//  ZM_ImgLImg_TVCell.m
//  YYFMMall
//
//  Created by chenzm on 2019/9/10.
//  Copyright © 2019 YuYou1. All rights reserved.
//

#import "ZM_ImgLImg_TVCell.h"

@interface ZM_ImgLImg_TVCell()

@end

@implementation ZM_ImgLImg_TVCell

#pragma mark - 赋值
-(void)setCellByLeftImgStr:(NSString *)leftImgStr rightImgStr:(NSString *)rightImgStr lblStr:(NSString *)lblStr{
    
    self.leftImgV.image = kImage(leftImgStr);
    self.rightImgV.image = kImage(rightImgStr);
    self.lbl.text = kIsEmptyStr(lblStr)?@"":lblStr;
    
    [_leftImgV mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(self.leftImgV.image.size);
        make.centerY.mas_equalTo(self);
        make.left.mas_equalTo(15);
    }];
    
    [_rightImgV mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(self.rightImgV.image.size);
        make.centerY.mas_equalTo(self);
        make.right.mas_equalTo(-15);
    }];
}


-(void)setLeftImgStr:(NSString *)leftImgStr{
    _leftImgStr = leftImgStr;
    self.leftImgV.image = kImage(leftImgStr);
    [self.leftImgV mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(self.leftImgV.image.size);
        make.centerY.mas_equalTo(self);
        make.left.mas_equalTo(15);
    }];
}

-(void)setRightImgStr:(NSString *)rightImgStr{
    _rightImgStr = rightImgStr;
    self.rightImgV.image = kImage(rightImgStr);
    [self.rightImgV mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(self.rightImgV.image.size);
        make.centerY.mas_equalTo(self);
        make.right.mas_equalTo(-15);
    }];
}


-(void)setLeftImg_mar:(CGFloat)leftImg_mar{
    _leftImg_mar = leftImg_mar;
    [_lbl mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(leftImg_mar);
        make.right.mas_equalTo(self.rightImgV.mas_right).offset(-6);
        make.centerY.mas_equalTo(self);
    }];
}


-(void)setImg_fixSize:(CGSize)img_fixSize{
    _img_fixSize = img_fixSize;
    [self.leftImgV mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(img_fixSize);
        make.centerY.mas_equalTo(self);
        make.left.mas_equalTo(15);
    }];
}


#pragma mark - Methods


#pragma mark - Intial
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self setUpBaseData];
        [self setUpUI];
    }
    return self;
}

///基本数据设置
-(void)setUpBaseData{
    
}
///添加控件
-(void)setUpUI{
    [self leftImgV];
    [self rightImgV];
    [self lbl];
    [self lineV];
}


#pragma mark - 布局
-(void)layoutSubviews{
    [super layoutSubviews];
    
}


#pragma mark - lazyLoad
-(UIImageView *)leftImgV{
    if (!_leftImgV) {
        _leftImgV = [UIImageView new];
        _leftImgV.contentMode = UIViewContentModeScaleToFill;
        [self addSubview:_leftImgV];
        [_leftImgV mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(kSize(15, 15));
            make.centerY.mas_equalTo(self);
            make.left.mas_equalTo(15);
        }];
    }
    return _leftImgV;
}

-(UIImageView *)rightImgV{
    if (!_rightImgV) {
        _rightImgV = [UIImageView new];
        _rightImgV.contentMode = UIViewContentModeScaleToFill;
        [self addSubview:_rightImgV];
        [_rightImgV mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(kSize(15, 15));
            make.centerY.mas_equalTo(self);
            make.right.mas_equalTo(self).offset(-15);
        }];
    }
    return _rightImgV;
}




-(UILabel *)lbl{
    if (!_lbl) {
        _lbl = [UILabel new];
        _lbl.font = kMediumFont(15);
        _lbl.textColor = kBlackColor;
        _lbl.textAlignment = NSTextAlignmentLeft;
        [self addSubview:_lbl];
        [_lbl mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.leftImgV.mas_right).offset(6);
            make.right.mas_equalTo(self.rightImgV.mas_right).offset(-6);
            make.centerY.mas_equalTo(self);
        }];
    }
    return _lbl;
}


-(UIView *)lineV{
    if (!_lineV) {
        _lineV = [UIView new];
        _lineV.backgroundColor = kHexColor(0xEEEEEE);
        [self addSubview:_lineV];
        [_lineV mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.mas_equalTo(self);
            make.left.mas_equalTo(15);
            make.right.mas_equalTo(-15);
            make.height.mas_equalTo(1);
        }];
    }
    return _lineV;
}

@end

